<template>
  <nav>
    <router-link class="tab-bar" to="/home">
    <div class="icon"><i class="iconfont icon-shouye"></i></div>
    <div>Home</div>
    </router-link>
    <router-link class="tab-bar" to="/cate">
    <div class="icon"><i class="iconfont icon-fenlei"></i></div>
    <div>Categroy</div>
    </router-link>
    <router-link class="tab-bar" to="/car">
    <div class="icon">
      <van-badge :content="$store.state.cartNum" max="9">
        <i class="iconfont icon-24gl-cartFull4"></i>
      </van-badge>
    </div>
    <div>ShopCar</div>
    </router-link> 
    <router-link class="tab-bar" to="/about">
    <div class="icon"><i class="iconfont icon-gerenzhongxin"></i></div>
    <div>User</div>
    </router-link>
  </nav>
  <router-view/>
</template>

<script>
import {useStore} from 'vuex';
import {onMounted } from 'vue';
export default {
  
  setup() {
    const store = useStore();
    onMounted(()=>{
      if(store.state.user.isLogin === true){
        store.dispatch('updateCart');
      }
      
    })
  },
}
</script>

<style lang="scss">
@import "assets/css/base.css";
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

nav {
  background-color: #f6f6f6;
  display: flex;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  box-shadow: 0 -3px 1px rgba(100, 100, 100, 0.1);
  z-index: 9999;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: var(--color-hight-text);
    }
  }
  .iconfont {
    font-size: 24px !important;
  }
  .tab-bar{
    flex:1;
    text-align: center;
    height: 50px;
    font-size: var(--font-size);
  }
  .tab-bar .icon{
      width:24px;
      height:24px;
      margin-top: 5px;
      display: inline-block; 
      
  }


}
</style>
